package exception;

import be.kuleuven.cs.som.annotate.Basic;
import be.kuleuven.cs.som.annotate.Immutable;

/**
 * A runtime exception class. When a position that is not valid would be made, this Exception is thrown.
 * 
 * @author Molderez Tom, 2de bach Ingenieurswetenschappen Computerwetenschappen-Elektrotechniek and Reniers Jorn, 2de bach Ingenieurswetenschappen Werktuigkunde-Computerwetenschappen
 * @version 1.0
 *
 */
public class IllegalPositionException extends RuntimeException {

	private static final long serialVersionUID = 1L;
	
	/**
	 * Creates a new IllegalPositionException for the given position.
	 * 
	 * @param x The x-coordinate of the illegal position.
	 * @param y The y-coordinate of the illegal position.
	 * @param message The error message.
	 * @effect
	 * 		| super(message)
	 * @post 
	 * 		| (new this).getX() == x
	 * @post
	 * 		| (new this).getY() == y
	 */
	public IllegalPositionException(long x, long y, String message) {
		super(message);
		this.x=x;
		this.y=y;
		}
	
	/**
	 * Returns the message with this exception.
	 */
	@Override
	@Basic @Immutable
	public String getMessage(){
		return "Illegal Position at " + x +"-" + y + ", message: " + super.getMessage(); 
	}
	
	/**
	 * Returns the x-value of the illegal position.
	 */
	@Basic @Immutable
	public long getX(){
		return x;
	}
	
	private final long x;
	
	/**
	 * Returns the y-value of the illegal position.
	 */
	@Basic @Immutable
	public long getY(){
		return y;
	}
	
	private final long y;
}
